# Ccompiler
CC= gcc

# Executable name
BIN= ld42

# Source and build paths
SRC_DIR= ./src
BUILD_DIR= ./build

# Source files
SRCS=main.c\
window.c\
event.c\
images_diffuse.c\
loops.c particle.c\
renderer.c\
vector.c\
entity.c\
component.c\
button.c\
game.c\
icon.c\
stb_imp.c\
player.c\
satellite.c\
bullet.c\
hitbox.c\
explosions.c\
screenshot.c\
hitpoint.c\
random.c\
basic_spray.c\
util.c\
help_text.c\
background.c\
levels.c\
weapon_choice.c\
triangle_ship.c\
cycle_ship.c\
missile_ship.c\
mothership.c


# Sprites


# Object files to build
OBJS= $(SRCS:%.c=%.o)

# Dependencies for each source
DEPS= $(OBJS:%.o=$(BUILD_DIR)/%.d)

# Flags for the compiler
CFLAGS= -O2 -Wall -Wno-unused-variable -lglfw3 -lopengl32 -lgdi32 -lpthread -lzgcl -lsdl2 -lSDL2_mixer

# Default path for make install
INSTALL_PATH?=/usr/local

$(BIN) : $(OBJS:%=$(BUILD_DIR)/%)
#build/shoehorn_sdl.o
	$(CC) $^ build/shoehorn_sdl.o -o $@ $(CFLAGS)

-include $(DEPS)

$(BUILD_DIR)/%.o : $(SRC_DIR)/%.c
	mkdir -p $(@D)
	$(CC) -MMD -c $< -o $@ $(CFLAGS)
	
shoehorn:
	gcc -c src/shoehorn_sdl.c -o build/shoehorn_sdl.o -lmingw32 -lsdl2 -lsdl2_mixer

.PHONY : clean install windows sprite
clean :
	rm -rf $(BUILD_DIR)
	rm $(BIN) || rm $(BIN).exe
	
sprite:
	make -C sprite

install : $(BIN)
	cp $(BIN) $(INSTALL_PATH)/bin
    
windows : $(OBJS:%=$(BUILD_DIR)/%)
	$(CC) $^ build/shoehorn_sdl.o -o WarpTunnel.exe $(CFLAGS) -mwindows